package com.multithread;

import java.util.ArrayList;
import java.util.List;

public class TestThread {
	public static void main(String args[]) {
		   
	      /*RunnableDemo R1 = new RunnableDemo( "Thread-1");
	      R1.start();
	      
	      RunnableDemo R2 = new RunnableDemo( "Thread-2");
	      R2.start();*/
	      
	      
	      
	      List<String> workList = new ArrayList<String>();
	      
	      for(int i=0;i<1000; i++){
	    	  workList.add("aaaaaaaaa");
	      }
	      int threads = 5;
	      TestThread testThread = new TestThread();
	      int blockSize = (workList.size() + threads - 1)/threads;
	      for(int i = 0; i < threads;i ++) {
	    	  int start = i * blockSize;
	    	   int end = Math.min((i + 1) * blockSize, workList.size());
	    	   final List<String> someWork = workList.subList(start, end);
	         testThread.submit(new Runnable() {
	             public void run() {
	                process(someWork);
	             }
	         });
	      }
	      
	      
	      
	      
	   }   
	
	public void submit(Runnable run) {
		System.out.println("aaaaaaaaaaaaaaaaaaaa");
	}
	
	public static void process(List<String> subList) {
	
		for(String str:subList){
			System.out.println(str);
		}
		
	}
}
